package com.itheima.table01;

import com.itheima.bean.Card;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.InputStream;
import java.util.List;

public class Test01 {

    @Test
    public void selectAll() throws Exception {
        InputStream is = Resources.getResourceAsStream("MyBatisConfig.xml");
        SqlSessionFactory build = new SqlSessionFactoryBuilder().build(is);
        SqlSession sqlSession = build.openSession(true);
        OneToOneMapper mapper= sqlSession.getMapper(OneToOneMapper.class);
        List<Card> cards = mapper.selectAll();
        for (Card card : cards) {
            System.out.println(card);
        }
        is.close();
        sqlSession.close();

    }
}
